package main

import (
	"fmt"
	"unsafe"
)

func main() {
	var num float32 = 3.12
	fmt.Printf("num %v--%f, type %T, size %d\n", num, num, num, unsafe.Sizeof(num))

	var num1 float64 = 3.12
	fmt.Printf("num1 %v--%f, type %T, size %d\n", num1, num1, num1, unsafe.Sizeof(num1))

	var num2 float64 = 3.123456789
	fmt.Printf("num2 %v--%f--%.2f, type %T, size %d\n", num2, num2, num2, unsafe.Sizeof(num2))

	var num3 float32 = 3.12e2
	fmt.Printf("num3 %v--%f, type %T, size %d\n", num3, num3, num3, unsafe.Sizeof(num3))

	var num4 float32 = 3.12e-2
	fmt.Printf("num4 %v--%f, type %T, size %d\n", num4, num4, num4, unsafe.Sizeof(num4))

	// 精度丢失问题
	var num5 float32 = 33.31
	fmt.Printf("num4 %v--%f\n", num5*100, num5*100)

	//类型转换
	a1 := 5
	a2 := float32(a1)
	fmt.Printf("%T %T\n", a1, a2)

	b1 := 3.23
	b2 := float32(b1)
	fmt.Printf("%T %T\n", b1, b2)

	c1 := 3.23
	c2 := int8(c1)
	fmt.Printf("%T %T\n", c1, c2)

	var flag bool
	fmt.Printf("flag %v, type %T, size %d\n", flag, flag, unsafe.Sizeof(flag))
}
